---
title: getFallbacksAsync
description: Returns the fallback values of the schema.
source: /methods/getFallbacks/getFallbacksAsync.ts
contributors:
  - fabian-hiller
  - EltonLobo07
---

import { ApiList, Link, Property } from '~/components';
import { properties } from './properties';

# getFallbacksAsync

Returns the fallback values of the schema.

> The difference to <Link href='../getFallback/'>`getFallback`</Link> is that for object and tuple schemas this function recursively returns the fallback values of the subschemas instead of `undefined`.

```ts
const values = v.getFallbacksAsync<TSchema>(schema);
```

## Generics

- `TSchema` <Property {...properties.TSchema} />

## Parameters

- `schema` <Property {...properties.schema} />

## Returns

- `values` <Property {...properties.values} />

## Examples

The following examples show how `getFallbacksAsync` can be used.

### New user fallbacks

Get the fallback values of a new user schema.

```ts
import { getAnyUniqueUsername, isUsernameUnique } from '~/api';

const NewUserSchema = v.objectAsync({
  username: v.fallbackAsync(
    v.pipeAsync(v.string(), v.minLength(3), v.checkAsync(isUsernameUnique)),
    getAnyUniqueUsername
  ),
  password: v.pipe(v.string(), v.minLength(8)),
});

const fallbackValues = await v.getFallbacksAsync(NewUserSchema);
/*
  {
    username: "cookieMonster07",
    password: undefined
  }
*/
```

## Related

The following APIs can be combined with `getFallbacksAsync`.

### Schemas

<ApiList
  items={[
    'any',
    'array',
    'bigint',
    'blob',
    'boolean',
    'custom',
    'date',
    'enum',
    'exactOptional',
    'file',
    'function',
    'instance',
    'intersect',
    'lazy',
    'literal',
    'looseObject',
    'looseTuple',
    'map',
    'nan',
    'never',
    'nonNullable',
    'nonNullish',
    'nonOptional',
    'null',
    'nullable',
    'nullish',
    'number',
    'object',
    'objectWithRest',
    'optional',
    'picklist',
    'promise',
    'record',
    'set',
    'strictObject',
    'strictTuple',
    'string',
    'symbol',
    'tuple',
    'tupleWithRest',
    'undefined',
    'undefinedable',
    'union',
    'unknown',
    'variant',
    'void',
  ]}
/>

### Methods

<ApiList
  items={[
    'assert',
    'config',
    'fallback',
    'keyof',
    'message',
    'omit',
    'partial',
    'pick',
    'pipe',
    'required',
    'unwrap',
  ]}
/>

### Async

<ApiList
  items={[
    'arrayAsync',
    'customAsync',
    'exactOptionalAsync',
    'fallbackAsync',
    'intersectAsync',
    'lazyAsync',
    'looseObjectAsync',
    'looseTupleAsync',
    'mapAsync',
    'nonNullableAsync',
    'nonNullishAsync',
    'nonOptionalAsync',
    'nullableAsync',
    'nullishAsync',
    'objectAsync',
    'objectWithRestAsync',
    'optionalAsync',
    'partialAsync',
    'pipeAsync',
    'recordAsync',
    'requiredAsync',
    'setAsync',
    'strictObjectAsync',
    'strictTupleAsync',
    'tupleAsync',
    'tupleWithRestAsync',
    'unionAsync',
    'variantAsync',
  ]}
/>
